#!/usr/bin/bash
#1.3指定后缀名，来确定文件类型；
:<<EOF
读取用户写入的文件类型
然后用循环系统文件 和文件类型判断 
if 1 则移动，并输入要移动的位置，
if 0 则提示未找到
EOF


timeDate=$(date)
echo "Beijing Time: ${timeDate}"
cd /c/Users/沈青宸/Desktop
read -p "please enter file category you want to move, eg: .docx           :" fileCate

i=0;
for fname in ./*
do
	((i++))
	echo "${fname},这是本目录下的第${i}个文件或文件夹！";
	echo "${fname##*.}";echo "${fileCate#.}"
	if [[ "${fname##*.}" == "${fileCate#.}" ]];then    
		echo -e "\nSTART----------------------------------------------"
		echo "${fname}  it's the ${fileCate} file !  "
		read -p "Do you want to move it ?  1/0 " var2
		if [[ "${var2}" == "1" ]];then            
			read -p "which diractory you wang to move?"  dirPath
			echo "diractory is ${dirPath}"
			mv ${fname} ${dirPath} && echo -e "\e[1;32m [OK]   \e[0m" || echo -e "\e[1;32m [FAILD]   \e[0m"      
			echo -e "END----------------------------------------------\n"
		else
			echo -e "END----------------------------------------------\n"
		continue
		fi
	fi
done

#1.4批处理操作